	package com.tnr.scgcxx.dao.safty;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.dq.base.page.PageParam;

import com.tnr.scgcxx.dto.RoleDto;
import com.tnr.scgcxx.model.Role;

public interface RoleDao {
	
	@Select("select ro_id,ro_name,ro_remark,ro_status from sys_role")
	public List<Role> findAllRoles();
	
	//@Select("select ro_id,ro_name,ro_remark,ro_status from sys_role")
	public List<Role> findRolesPage(PageParam pageParam);

	@Insert("insert into sys_role(ro_id,ro_name,ro_remark,ro_status) values(#{ro_id},#{ro_name},#{ro_remark},#{ro_status})")
	public int insertRole(RoleDto dto);
	
	public int updateRole(RoleDto dto);
	
	@Select("select ro_id,ro_name,ro_remark,ro_status from sys_role where ro_id=#{ro_id}")
	public Role findRolebyId(String ro_id);

	public int deleteRoleByIds(Integer... ro_ids);

	public int updateRoleStatusByIds(@Param("status") String status, @Param("ro_ids") Integer[] ro_ids);

	@Select("select rm.m_id from sys_rm rm join sys_module m on rm.m_id=m.m_id where rm.ro_id=#{roleId} and m.m_status='55' and m.m_ismenu=1 ")
	public List<Integer> findRoleModuleIds(Integer roleId);
	
	public int insertRoleModule(@Param("roleId") Integer roleId, @Param("menuIds") Integer[] menuIds);

	@Delete("delete from sys_rm where ro_id=#{roleId} ")
	public int deleteRoleModulesById(Integer roleId);

}
